package com.whiteape.book.net;

import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.Single;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public interface HttpApi {

    @GET
    Single<Response<String>> get(@Url String url,
                                 @HeaderMap Map<String, String> headers);

    @POST
    Single<Response<String>> post(@Url String url,@HeaderMap Map<String, String> headers,
                                 @Body RequestBody body);
    @GET
    Observable<Response<String>> getObservable(@Url String url,
                                 @HeaderMap Map<String, String> headers);
    @GET
    Single<Response<String>> getMap(@Url String url,
                                        @QueryMap(encoded = true) Map<String, String> queryMap,
                                        @HeaderMap Map<String, String> headers);


    @FormUrlEncoded
    @POST
    Single<Response<String>> postMap(@Url String url,
                                         @FieldMap(encoded = true) Map<String, String> fieldMap,
                                         @HeaderMap Map<String, String> headers);

    @POST
    Single<Response<String>> postJson(@Url String url,
                                          @Body RequestBody body,
                                          @HeaderMap Map<String, String> headers);

    @Streaming
    @GET
    Call<ResponseBody> download(@Url String url);

    @Streaming
    @GET
    Single<ResponseBody> downloadByRx(@Url String url);
}
